import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
import Layout from '@/layout1/index.vue'
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    hidden: true
  },
  {
    path: '/routerpage',
    component: () => import('@/views/login/routerpage.vue'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404.vue'),
    hidden: true
  },
  {
    path: '/',
    redirect: '/login',
  },
  {
    path: '/table',
    component: Layout,
    children: [
      {
        path: 'view',
        name: 'ExpertView',
        component: () => import('@/views/table/view.vue'),
        meta: { title: '专家详情', icon: 'el-icon-view' },
        hidden: true
      }
    ]
  },
  {
    path: '/example',
    component: Layout,
    meta: { title: '专家库管理', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index.vue'),
        meta: { title: '专家库管理', icon: 'el-icon-s-help' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index.vue'),
        meta: { title: '专家库管理专家信息', icon: 'tree' }
      },
    ],
  },
  {
    path: '/form',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index.vue'),
        meta: { title: '查看信息', icon: 'form' }
      },
      {
        path: 'indexb',
        name: 'Formb',
        component: () => import('@/views/form/indexb.vue'),
        meta: { title: '查看信息', icon: 'form' }
      }
    ]
  },
  {
    path: '/Review',
    redirect: '/Review/index',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Review',
        component: () => import('@/views/Review/index.vue'),
        meta: { title: '专家抽取管理', icon: 'el-icon-user-solid' }
      },
    ]
  },
  {
    path: '/appraise',
    redirect: '/appraise/index',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'appraise',
        component: () => import('@/views/appraise/index.vue'),
        meta: { title: '专家抽取管理', icon: 'el-icon-user-solid' }
      },
    ]
  },
  {
    path: '/dashboard',
    redirect: '/dashboard/count',
    component: Layout,
    children: [
      {
        path: 'count',
        name: 'count',
        component: () => import('@/views/dashboard/count.vue'),
        meta: { title: '统计信息', icon: 'el-icon-user-solid' }
      },
      {
        path: 'index',
        name: 'dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '项目入库管理', icon: 'el-icon-user-solid' }
      },
    ]
  },

  {
    path: '/expert-exit',
    redirect: '/expert-exit/index',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'ExpertExit',
        component: () => import('@/views/expertExit/index.vue'),
        meta: {
          title: '专家出库管理',
          icon: 'el-icon-user-solid'
        }
      }
    ]
  },
  {
    path: '/platform',
    redirect: '/platform/index',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'people',
        component: () => import('@/views/platform/index.vue'),
        meta: {
          title: '用户管理',
          icon: 'el-icon-user-solid'
        }
      },
      {
        path: 'menu',
        name: 'menu',
        component: () => import('@/views/platform/menu.vue'),
        meta: {
          title: '菜单管理',
          icon: 'el-icon-user-solid'
        }
      },
      {
        path: 'part',
        name: 'part',
        component: () => import('@/views/platform/part.vue'),
        meta: {
          title: '部门管理',
          icon: 'el-icon-user-solid'
        }
      },
      {
        path: 'role',
        name: 'role',
        component: () => import('@/views/platform/role.vue'),
        meta: {
          title: '角色管理',
          icon: 'el-icon-user-solid'
        }
      },
      {
        path: 'monitor',
        name: 'monitor',
        component: () => import('@/views/platform/monitor.vue'),
        meta: {
          title: '系统监控',
          icon: 'el-icon-user-solid'
        }
      }
      ,
      {
        path: 'loginlog',
        name: 'loginlog',
        component: () => import('@/views/platform/log/login.vue'),
        meta: {
          title: '登录日志',
          icon: 'el-icon-user-solid'
        }
      }
      ,
      {
        path: 'operatelog',
        name: 'operatelog',
        component: () => import('@/views/platform/log/operate.vue'),
        meta: {
          title: '操作日志',
          icon: 'el-icon-user-solid'
        }
      }      ,
      {
        path: 'unusuallog',
        name: 'unusuallog',
        component: () => import('@/views/platform/log/unusual.vue'),
        meta: {
          title: '异常日志',
          icon: 'el-icon-user-solid'
        }
      }

    ]
  },
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/dashboard',
  //   children: [{
  //     path: 'dashboard',
  //     name: 'Dashboard',
  //     component: () => import('@/views/dashboard/index'),
  //     meta: { title: '专家入库管理', icon: 'dashboard' }
  //   }]
  // },

  // {
  //   path: '/example',
  //   component: Layout,
  //   redirect: '/example/table',
  //   name: 'Example',
  //   meta: { title: '专家库管理', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'table',
  //       name: 'Table',
  //       component: () => import('@/views/table/index'),
  //       meta: { title: '专家库管理', icon: 'table' }
  //     },
  //     {
  //       path: 'tree',
  //       name: 'Tree',
  //       component: () => import('@/views/tree/index'),
  //       meta: { title: '专家库管理专家信息', icon: 'tree' }
  //     }
  //   ]
  // },

  // {
  //   path: '/form',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'Form',
  //       component: () => import('@/views/form/index'),
  //       meta: { title: '查看信息', icon: 'form' }
  //     }
  //   ]
  // },

  // {
  //   path: '/expert-exit',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'ExpertExit',
  //       component: () => import('@/views/expertExit/index'),
  //       meta: {
  //         title: '专家出库管理',
  //         icon: 'el-icon-user-solid'
  //       }
  //     }
  //   ]
  // },
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
